local console = require 'jass.console'
local runtime = require 'jass.runtime'
local japi    = require 'jass.japi'
local storm   = require 'jass.storm'
local config  = require 'lua.path'

local local_test = false 
local local_map_path = ""
local version = "0"
if config then 
    local_test = config.local_test 
    local_map_path = config.local_map_path
    version = config.version
end

package.version = version 
package.local_test = local_test
package.local_map_path = local_map_path
package.load_step = 1
console.enable = local_test
print = console.write
runtime.sleep = true
runtime.handle_level = 0

package.path = package.path .. ';'
.. local_map_path .. '?.lua;'
.. local_map_path .. '?\\init.lua;'
.. local_map_path .. 'scripts\\?.lua;'
.. local_map_path .. 'scripts\\?\\init.lua;'
.. local_map_path .. 'scripts\\core\\?.lua;'
.. local_map_path .. 'scripts\\core\\?\\init.lua;'

--[[错误汇报]]
local japi = require 'jass.japi'
local md5 = japi.md5
local lock = {}
function runtime.error_handle(msg)
    local error_md5 = md5( msg )
    if lock[error_md5] then
        return 
    end
    lock[error_md5] = 1
    print("---------------------------------------")
    print("--------------请截图发给作者------------")
    print("---------------------------------------")
    print(tostring(msg) .. "\n")
    print("---------------------------------------")
    print(debug.traceback() .. "\n")
    print("---------------------------------------")
end

japi.SetOwner "艾豆"

xpcall( function() 
    require "scripts.init" 
end , function(msg)
    console.enable = true
    runtime.error_handle(msg)
end)
